<!--<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<c:set var="path" value="${pageContext.request.contextPath}" />-->
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
	content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<link rel="Bookmark" href="/favicon.ico">
<link rel="Shortcut Icon" href="/favicon.ico" />
<link rel="stylesheet" type="text/css"
	href="/Medical_Instrument/statics/h-ui/css/H-ui.min.css" />
<link rel="stylesheet" type="text/css"
	href="/Medical_Instrument/statics/h-ui.admin/css/H-ui.admin.css" />
<link rel="stylesheet" type="text/css"
	href="/Medical_Instrument/statics/lib/Hui-iconfont/1.0.8/iconfont.css" />
<link rel="stylesheet" type="text/css"
	href="/Medical_Instrument/statics/h-ui.admin/skin/default/skin.css" id="skin" />
<link rel="stylesheet" type="text/css"
	href="/Medical_Instrument/statics/h-ui.admin/css/style.css" />

<title>添加操作员</title>
<meta name="keywords" content="医疗器械与医药管理系统">
<meta name="description" content="医疗器械与医药管理系统">
</head>
<body>
	<article class="page-container">
		<!-- id:form-member-add -->
		<form action="${path}/operator/addOperator" method="post"
			class="form form-horizontal" id="form" onsubmit="return setPwd()">
			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-3"><span
					class="c-red">*</span>编号：</label>
				<div class="formControls col-xs-8 col-sm-9">
					<input type="text" class="input-text" value="" placeholder=""
						id="operatorId" name="operatorId" onblur="judgeNo()">
				</div>
			</div>


			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-3"><span
					class="c-red">*</span>姓名：</label>
				<div class="formControls col-xs-8 col-sm-9">
					<input type="text" class="input-text" value="" placeholder=""
						id="operatorName" name="operatorName">
				</div>
			</div>

			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-3"><span
					class="c-red">*</span>输入码：</label>
				<div class="formControls col-xs-8 col-sm-9">
					<input type="text" class="input-text" value="" placeholder=""
						id="inputCode" name="inputCode" readonly="readonly">
				</div>
			</div>

			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-3"><span
					class="c-red">*</span>密码：</label>
				<div class="formControls col-xs-8 col-sm-9">
					<input type="password" class="input-text" id="operatorPassword"
						name="operatorPassword">
				</div>
			</div>

			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-3"><span
					class="c-red">*</span>再次输入密码：</label>
				<div class="formControls col-xs-8 col-sm-9">
					<input type="password" class="input-text" id="re_operatorPassword"
						name="re_operatorPassword">
				</div>
			</div>

			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-3"><span
					class="c-red">*</span>性别：</label>
				<div class="formControls col-xs-8 col-sm-9 skin-minimal">
					<div class="radio-box">
						<input name="gender" type="radio" id="sex-1" value="1" checked>
						<label for="sex-1">男</label>
					</div>
					<div class="radio-box">
						<input name="gender" type="radio" value="0" id="sex-2"> <label
							for="sex-2">女</label>
					</div>
				</div>
			</div>
			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-3"><span
					class="c-red">*</span>手机：</label>
				<div class="formControls col-xs-8 col-sm-9">
					<input type="text" class="input-text" value="" placeholder=""
						id="contactWay" name="contactWay">
				</div>
			</div>
			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-3">岗位：</label>
				<div class="formControls col-xs-8 col-sm-9">
					<select name="postId" id="postId"
						style="width: 110px;height: 40px;font-size: 16px;">
					</select>
				</div>
			</div>

			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-3">商品进价信息查看权：</label>
				<div class="formControls col-xs-8 col-sm-9">
					<input type="checkbox" id="lookPurchasePrice"
						name="lookPurchasePrice" value="0" />
				</div>
			</div>

			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-3">销售优惠限额：</label>
				<div class="formControls col-xs-8 col-sm-9">
					<input type="text" class="input-text" value=""
						placeholder="用于销售收款时填写的优惠金额上限" id="discounts" name="discounts">

				</div>
			</div>

			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-3">备注：</label>
				<div class="formControls col-xs-8 col-sm-9">
					<textarea name="description" cols="" rows="" class="textarea"
						placeholder="说点什么...最少输入10个字符"
						onKeyUp="$.Huitextarealength(this,100)"></textarea>
					<p class="textarea-numberbar">
						<em class="textarea-length">0</em>/100
					</p>
				</div>
			</div>
			<div class="row cl">
				<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
					<input class="btn btn-primary radius" type="button"
						onclick="checkInput()" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
				</div>
			</div>
		</form>
	</article>

	<!--footer 作为公共模版分离出去-->
	<script type="text/javascript"
		src="/Medical_Instrument/statics/lib/jquery/1.9.1/jquery.min.js"></script>
	<script type="text/javascript"
		src="/Medical_Instrument/statics/lib/layer/2.4/layer.js"></script>
	<script type="text/javascript"
		src="/Medical_Instrument/statics/h-ui/js/H-ui.min.js"></script>
	<script type="text/javascript"
		src="/Medical_Instrument/statics/h-ui.admin/js/H-ui.admin.js"></script>
	<!--footer 作为公共模版分离出去-->

	<!--请在下方写此页面业务相关的脚本-->
	<script type="text/javascript"
		src="/Medical_Instrument/statics/lib/My97DatePicker/4.8/WdatePicker.js"></script>
	<script type="text/javascript"
		src="/Medical_Instrument/statics/lib/jquery.validation/1.14.0/jquery.validate.js"></script>
	<script type="text/javascript"
		src="/Medical_Instrument/statics/lib/jquery.validation/1.14.0/validate-methods.js"></script>
	<script type="text/javascript"
		src="/Medical_Instrument/statics/lib/jquery.validation/1.14.0/messages_zh.js"></script>
	<script type="text/javascript" src="/Medical_Instrument/statics/js/utils/MD5.js"></script>
	<script type="text/javascript">
		$(function() {
			var postId = $("#postId");

			//填充岗位下拉列表
			$.ajax({
				type : "POST",
				url : "${path}/post/getPostList",
				dataType : "json",
				success : function(data) {
					if (data != null) {
						postId.html("");
						var options = "<option value=\"0\">请选择</option>";
						for ( var i = 0; i < data.length; i++) {
							options += "<option value=\""+data[i].postId+"\">"
									+ data[i].postChineseName + "</option>";
						}
						postId.html(options);
					}
				},
				error : function(data) {//当访问时候，404，500 等非200的错误状态码
					/* validateTip(postId.next(),{"color":"red"},imgNo+" 获取岗位列表error",false); */
				}
			});

			$('.skin-minimal input').iCheck({
				checkboxClass : 'icheckbox-blue',
				radioClass : 'iradio-blue',
				increaseArea : '20%'
			});

			$("#form-member-add").validate({
				rules : {
					username : {
						required : true,
						minlength : 2,
						maxlength : 16
					},
					sex : {
						required : true,
					},
					mobile : {
						required : true,
						isMobile : true,
					},
					email : {
						required : true,
						email : true,
					},
					uploadfile : {
						required : true,
					},

				},
				onkeyup : false,
				focusCleanup : true,
				success : "valid",
				submitHandler : function(form) {
					//$(form).ajaxSubmit();
					var index = parent.layer.getFrameIndex(window.name);
					//parent.$('.btn-refresh').click();
					parent.layer.close(index);
				}
			});

		});

		$("#operatorName").blur(
				function() {
					$.post("${path}/inputCode/getInputCodeByName", "name="
							+ $("#operatorName").val(), callBack);
					function callBack(data) {
						var obj = JSON.parse(data);
						$("#inputCode").val(obj.inputCode);
					}
				});

		function setPwd() {
			var name = $("#operatorName").val();
			var pwd = $("#operatorPassword").val();
			var pswd = MD5(name + "#" + pwd);
			$("#operatorPassword").val(pswd);
		}

		function checkInput() {
			if (judgeNo() == false) {
				return;
			}

			var pwd = $("#operatorPassword").val();
			var repwd = $("#re_operatorPassword").val();
			if (pwd != repwd) {
				layer.msg('两次密码输入不一致！', {
					icon : 5,
					time : 5000
				});
				return;
			}
			if ($("input[type='checkbox']").is(':checked'))
				$("#lookPurchasePrice").val(1);
			setPwd();
			var data = $("form").serialize(); //序列化表单
			$.ajax({
				type : "POST",
				url : "${path}/operator/addOperator",
				data : data,
				dataType : "json",
				success : function(data) {
					if (data.result == "true") {
						//成功添加数据关闭当前窗口
						//获取当前打开的frame的index
						var index = parent.layer.getFrameIndex(window.name);
						parent.$("#btn-refresh").click();
						//关闭本身frame
						parent.layer.close(index);
					}
				},
				error : function(data) {
					layer.msg('发生错误，请稍后再试！', {
						icon : 5,
						time : 5000
					});
				}
			});

		}

		function judgeNo() {
			var no = $("#operatorId").val();
			$.ajax({
				type : "POST",
				url : "${path}/operator/judgeNo",
				data : {
					"no" : no
				},
				dataType : "json",
				success : function(data) {
					if (data.result == "true") {
						layer.msg("编号为" + no + "的操作员已存在，请重新输入！", {
							icon : 5,
							time : 5000
						});
						$("#operatorId").focus();
						return false;
					}
					return true;
				},
				error : function(data) {
					layer.msg('发生错误，请稍后再试！', {
						icon : 5,
						time : 5000
					});
				}
			});

		}
	</script>
	<!--请在上方写此页面业务相关的脚本-->
</body>
</html>